package domain;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class AudioFileFilter extends FileFilter implements java.io.FileFilter {
	
	String description;
	String extensions[] = new String[4];
	
	

	public AudioFileFilter() {
		super();
		description = "MP3 files (.mp3)";
		extensions[0] = "mp3";
	}

	@Override
	public boolean accept(File f) {
		if(f.isDirectory()){
			return true;
		}
		else{
			String path = f.getAbsolutePath().toLowerCase();
			for(int i=0,n=extensions.length; i<n; i++){
				String extension = extensions[i];
				if ((path.endsWith(extension) && (path.charAt(path.length() - extension.length() - 1)) == '.')) {
			          return true;
			    }
			}
		}
		return false;
	}

	@Override
	public String getDescription() {
		return description;
	}

}
